unit con_Genero;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Formulario_Padrao_Consulta, Grids, DBGrids, StdCtrls,
  TFlatButtonUnit, Buttons, ExtCtrls, DB, DBTables;

type
  TfrmCon_Genero = class(TFrmConsulta)
    Label1: TLabel;
    EdtDescricao: TEdit;
    DbgFaseProcesso: TDBGrid;
    Query1: TQuery;
    procedure BtnFecharClick(Sender: TObject);
    procedure EdtDescricaoKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure FormActivate(Sender: TObject);
  private
    { Private declarations }
     procedure FazConsulta;
  public
    { Public declarations }
    Gen_codigo : String;
  end;

var
  frmCon_Genero: TfrmCon_Genero;

implementation

uses Dm, clsGENERO;

var Genero : TGENERO;
    tds          : Tdatasource;
    tq           : Tquery;

{$R *.dfm}

procedure TfrmCon_Genero.BtnFecharClick(Sender: TObject);
begin
  inherited;
  Gen_codigo:=tq.fieldbyname('Gen_codigo').asstring;
  tds.free;
  tq.free;
end;

procedure TfrmCon_Genero.FazConsulta;
begin
  if EdtDescricao.text='' then
    EdtDescricao.text := ' ';
  Genero:=TGenero.Create;
  Genero.Consultar(tq,EdtDescricao.text);
  tq.open;
  Genero.free;
  dbgFaseProcesso.DataSource := tds;
  dbgFaseProcesso.Refresh;
end;

procedure TfrmCon_Genero.EdtDescricaoKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  inherited;
  if key=12 then begin
    FazConsulta;
    EdtDescricao.setfocus;
  end;
end;

procedure TfrmCon_Genero.FormActivate(Sender: TObject);
begin
  inherited;
  tds:=TDataSource.create(self);
  tq:=Tquery.create(self);
  tq.databasename:=dmint.db.databasename;
  tq.active:=False;
  tds.DataSet:=tq;
  fazconsulta;
  EdtDescricao.setfocus;
end;

end.
